home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume23 / pty / part06 < prev    next >
Encoding:
Internet Message Format  |  1991-01-08  |  14.2 KB

  1. Path: j.cc.purdue.edu!mentor.cc.purdue.edu!noose.ecn.purdue.edu!samsung!cs.utexas.edu!uunet!papaya.bbn.com!rsalz
  2. From: rsalz@bbn.com (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v23i036:  Run a program under a pty session, Part06/06
  5. Message-ID: <2886@litchi.bbn.com>
  6. Date: 10 Oct 90 14:17:14 GMT
  7. Organization: BBN Systems and Technologies, Cambridge MA
  8. Lines: 514
  9. Approved: rsalz@uunet.UU.NET
  10. X-Checksum-Snefru: e1cac7b9 4b5d3634 52ea5782 fd74f891
  11.  
  12. Submitted-by: Dan Bernstein <brnstnd@kramden.acf.nyu.edu>
  13. Posting-number: Volume 23, Issue 36
  14. Archive-name: pty/part06
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then feed it
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  21. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  22. # Contents:  err.h file.h file.h.new getopt.h logs.h master.h misc.h
  23. #   patch/TELNET.FTP sigler.h slave.h texts.h util/condom
  24. #   util/excloff.1 util/excloff.c util/exclon.c util/script
  25. #   util/script.tidy util/sess util/tiocsti.1 util/tiocsti.c
  26. #   util/tty.1 util/tty.c
  27. # Wrapped by rsalz@litchi.bbn.com on Wed Oct 10 10:11:43 1990
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. echo If this archive is complete, you will see the following message:
  30. echo '          "shar: End of archive 6 (of 6)."'
  31. if test -f 'err.h' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'err.h'\"
  33. else
  34.   echo shar: Extracting \"'err.h'\" \(385 characters\)
  35.   sed "s/^X//" >'err.h' <<'END_OF_FILE'
  36. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  37. X
  38. X#ifndef PTY_ERR_H
  39. X#define PTY_ERR_H
  40. X
  41. X#include <errno.h>
  42. Xextern int errno; /* not always defined in errno.h, grrrr */
  43. Xextern int sys_nerr;
  44. Xextern char *sys_errlist[];
  45. X
  46. Xextern void fatal();
  47. Xextern void fatalinfo();
  48. Xextern void fatalerr();
  49. Xextern void fatalerr2p();
  50. Xextern void fatalerrp();
  51. Xextern void warnerr2();
  52. X
  53. X#endif
  54. END_OF_FILE
  55.   if test 385 -ne `wc -c <'err.h'`; then
  56.     echo shar: \"'err.h'\" unpacked with wrong size!
  57.   fi
  58.   # end of 'err.h'
  59. fi
  60. if test -f 'file.h' -a "${1}" != "-c" ; then 
  61.   echo shar: Will not clobber existing file \"'file.h'\"
  62. else
  63.   echo shar: Extracting \"'file.h'\" \(224 characters\)
  64.   sed "s/^X//" >'file.h' <<'END_OF_FILE'
  65. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  66. X
  67. X#ifndef PTY_FILE_H
  68. X#define PTY_FILE_H
  69. X
  70. X#include <sys/file.h>
  71. X#ifdef BSD
  72. X#include <limits.h>
  73. X#endif
  74. X#include <fcntl.h>
  75. Xextern long lseek(); /* sigh. */
  76. X
  77. X#endif
  78. END_OF_FILE
  79.   if test 224 -ne `wc -c <'file.h'`; then
  80.     echo shar: \"'file.h'\" unpacked with wrong size!
  81.   fi
  82.   # end of 'file.h'
  83. fi
  84. if test -f 'file.h.new' -a "${1}" != "-c" ; then 
  85.   echo shar: Will not clobber existing file \"'file.h.new'\"
  86. else
  87.   echo shar: Extracting \"'file.h.new'\" \(224 characters\)
  88.   sed "s/^X//" >'file.h.new' <<'END_OF_FILE'
  89. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  90. X
  91. X#ifndef PTY_FILE_H
  92. X#define PTY_FILE_H
  93. X
  94. X#include <sys/file.h>
  95. X#ifdef BSD
  96. X#include <limits.h>
  97. X#endif
  98. X#include <fcntl.h>
  99. Xextern long lseek(); /* sigh. */
  100. X
  101. X#endif
  102. END_OF_FILE
  103.   if test 224 -ne `wc -c <'file.h.new'`; then
  104.     echo shar: \"'file.h.new'\" unpacked with wrong size!
  105.   fi
  106.   # end of 'file.h.new'
  107. fi
  108. if test -f 'getopt.h' -a "${1}" != "-c" ; then 
  109.   echo shar: Will not clobber existing file \"'getopt.h'\"
  110. else
  111.   echo shar: Extracting \"'getopt.h'\" \(250 characters\)
  112.   sed "s/^X//" >'getopt.h' <<'END_OF_FILE'
  113. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  114. X
  115. X#ifndef PTY_GETOPT_H
  116. X#define PTY_GETOPT_H
  117. X
  118. X/* The following should be in /usr/include/getopt.h but often aren't. */
  119. Xextern int getopt();
  120. Xextern char *optarg;
  121. Xextern int optind;
  122. X
  123. X#endif
  124. END_OF_FILE
  125.   if test 250 -ne `wc -c <'getopt.h'`; then
  126.     echo shar: \"'getopt.h'\" unpacked with wrong size!
  127.   fi
  128.   # end of 'getopt.h'
  129. fi
  130. if test -f 'logs.h' -a "${1}" != "-c" ; then 
  131.   echo shar: Will not clobber existing file \"'logs.h'\"
  132. else
  133.   echo shar: Extracting \"'logs.h'\" \(169 characters\)
  134.   sed "s/^X//" >'logs.h' <<'END_OF_FILE'
  135. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  136. X
  137. X#ifndef PTY_LOGS_H
  138. X#define PTY_LOGS_H
  139. X
  140. Xextern long now();
  141. Xextern int utmp();
  142. Xextern int wtmp();
  143. X
  144. X#endif
  145. END_OF_FILE
  146.   if test 169 -ne `wc -c <'logs.h'`; then
  147.     echo shar: \"'logs.h'\" unpacked with wrong size!
  148.   fi
  149.   # end of 'logs.h'
  150. fi
  151. if test -f 'master.h' -a "${1}" != "-c" ; then 
  152.   echo shar: Will not clobber existing file \"'master.h'\"
  153. else
  154.   echo shar: Extracting \"'master.h'\" \(138 characters\)
  155.   sed "s/^X//" >'master.h' <<'END_OF_FILE'
  156. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  157. X
  158. X#ifndef PTY_MASTER_H
  159. X#define PTY_MASTER_H
  160. X
  161. Xextern void master();
  162. X
  163. X#endif
  164. END_OF_FILE
  165.   if test 138 -ne `wc -c <'master.h'`; then
  166.     echo shar: \"'master.h'\" unpacked with wrong size!
  167.   fi
  168.   # end of 'master.h'
  169. fi
  170. if test -f 'misc.h' -a "${1}" != "-c" ; then 
  171.   echo shar: Will not clobber existing file \"'misc.h'\"
  172. else
  173.   echo shar: Extracting \"'misc.h'\" \(190 characters\)
  174.   sed "s/^X//" >'misc.h' <<'END_OF_FILE'
  175. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  176. X
  177. X#ifndef PTY_MISC_H
  178. X#define PTY_MISC_H
  179. X
  180. Xextern int sessdir();
  181. Xextern char *real_ttyname();
  182. Xextern void setusername();
  183. X
  184. X#endif
  185. END_OF_FILE
  186.   if test 190 -ne `wc -c <'misc.h'`; then
  187.     echo shar: \"'misc.h'\" unpacked with wrong size!
  188.   fi
  189.   # end of 'misc.h'
  190. fi
  191. if test -f 'patch/TELNET.FTP' -a "${1}" != "-c" ; then 
  192.   echo shar: Will not clobber existing file \"'patch/TELNET.FTP'\"
  193. else
  194.   echo shar: Extracting \"'patch/TELNET.FTP'\" \(69 characters\)
  195.   sed "s/^X//" >'patch/TELNET.FTP' <<'END_OF_FILE'
  196. Xuser anonymous pty
  197. Xcd pub
  198. Xtype binary
  199. Xget telnet.90.06.28.tar.Z
  200. Xquit
  201. END_OF_FILE
  202.   if test 69 -ne `wc -c <'patch/TELNET.FTP'`; then
  203.     echo shar: \"'patch/TELNET.FTP'\" unpacked with wrong size!
  204.   fi
  205.   # end of 'patch/TELNET.FTP'
  206. fi
  207. if test -f 'sigler.h' -a "${1}" != "-c" ; then 
  208.   echo shar: Will not clobber existing file \"'sigler.h'\"
  209. else
  210.   echo shar: Extracting \"'sigler.h'\" \(138 characters\)
  211.   sed "s/^X//" >'sigler.h' <<'END_OF_FILE'
  212. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  213. X
  214. X#ifndef PTY_SIGLER_H
  215. X#define PTY_SIGLER_H
  216. X
  217. Xextern void sigler();
  218. X
  219. X#endif
  220. END_OF_FILE
  221.   if test 138 -ne `wc -c <'sigler.h'`; then
  222.     echo shar: \"'sigler.h'\" unpacked with wrong size!
  223.   fi
  224.   # end of 'sigler.h'
  225. fi
  226. if test -f 'slave.h' -a "${1}" != "-c" ; then 
  227.   echo shar: Will not clobber existing file \"'slave.h'\"
  228. else
  229.   echo shar: Extracting \"'slave.h'\" \(135 characters\)
  230.   sed "s/^X//" >'slave.h' <<'END_OF_FILE'
  231. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  232. X
  233. X#ifndef PTY_SLAVE_H
  234. X#define PTY_SLAVE_H
  235. X
  236. Xextern void slave();
  237. X
  238. X#endif
  239. END_OF_FILE
  240.   if test 135 -ne `wc -c <'slave.h'`; then
  241.     echo shar: \"'slave.h'\" unpacked with wrong size!
  242.   fi
  243.   # end of 'slave.h'
  244. fi
  245. if test -f 'texts.h' -a "${1}" != "-c" ; then 
  246.   echo shar: Will not clobber existing file \"'texts.h'\"
  247. else
  248.   echo shar: Extracting \"'texts.h'\" \(273 characters\)
  249.   sed "s/^X//" >'texts.h' <<'END_OF_FILE'
  250. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  251. X
  252. X#ifndef PTY_TEXTS_H
  253. X#define PTY_TEXTS_H
  254. X
  255. Xextern char *ptyauthor[];
  256. Xextern char *ptyversion[];
  257. Xextern char *ptycopyright[];
  258. Xextern char *ptywarranty[];
  259. Xextern char *ptyusage[];
  260. Xextern char *ptyhelp[];
  261. X
  262. X#endif
  263. END_OF_FILE
  264.   if test 273 -ne `wc -c <'texts.h'`; then
  265.     echo shar: \"'texts.h'\" unpacked with wrong size!
  266.   fi
  267.   # end of 'texts.h'
  268. fi
  269. if test -f 'util/condom' -a "${1}" != "-c" ; then 
  270.   echo shar: Will not clobber existing file \"'util/condom'\"
  271. else
  272.   echo shar: Extracting \"'util/condom'\" \(44 characters\)
  273.   sed "s/^X//" >'util/condom' <<'END_OF_FILE'
  274. X#!/bin/sh
  275. X# Public domain.
  276. Xexec pty -0 "$@"
  277. END_OF_FILE
  278.   if test 44 -ne `wc -c <'util/condom'`; then
  279.     echo shar: \"'util/condom'\" unpacked with wrong size!
  280.   fi
  281.   chmod +x 'util/condom'
  282.   # end of 'util/condom'
  283. fi
  284. if test -f 'util/excloff.1' -a "${1}" != "-c" ; then 
  285.   echo shar: Will not clobber existing file \"'util/excloff.1'\"
  286. else
  287.   echo shar: Extracting \"'util/excloff.1'\" \(18 characters\)
  288.   sed "s/^X//" >'util/excloff.1' <<'END_OF_FILE'
  289. X.so man1/exclon.1
  290. END_OF_FILE
  291.   if test 18 -ne `wc -c <'util/excloff.1'`; then
  292.     echo shar: \"'util/excloff.1'\" unpacked with wrong size!
  293.   fi
  294.   # end of 'util/excloff.1'
  295. fi
  296. if test -f 'util/excloff.c' -a "${1}" != "-c" ; then 
  297.   echo shar: Will not clobber existing file \"'util/excloff.c'\"
  298. else
  299.   echo shar: Extracting \"'util/excloff.c'\" \(110 characters\)
  300.   sed "s/^X//" >'util/excloff.c' <<'END_OF_FILE'
  301. X/* Public domain. */
  302. X#include <sys/ioctl.h>
  303. X
  304. Xmain()
  305. X{
  306. X (void) ioctl(1,(unsigned long) TIOCNXCL,(char *) 0);
  307. X}
  308. END_OF_FILE
  309.   if test 110 -ne `wc -c <'util/excloff.c'`; then
  310.     echo shar: \"'util/excloff.c'\" unpacked with wrong size!
  311.   fi
  312.   # end of 'util/excloff.c'
  313. fi
  314. if test -f 'util/exclon.c' -a "${1}" != "-c" ; then 
  315.   echo shar: Will not clobber existing file \"'util/exclon.c'\"
  316. else
  317.   echo shar: Extracting \"'util/exclon.c'\" \(110 characters\)
  318.   sed "s/^X//" >'util/exclon.c' <<'END_OF_FILE'
  319. X/* Public domain. */
  320. X#include <sys/ioctl.h>
  321. X
  322. Xmain()
  323. X{
  324. X (void) ioctl(1,(unsigned long) TIOCEXCL,(char *) 0);
  325. X}
  326. END_OF_FILE
  327.   if test 110 -ne `wc -c <'util/exclon.c'`; then
  328.     echo shar: \"'util/exclon.c'\" unpacked with wrong size!
  329.   fi
  330.   # end of 'util/exclon.c'
  331. fi
  332. if test -f 'util/script' -a "${1}" != "-c" ; then 
  333.   echo shar: Will not clobber existing file \"'util/script'\"
  334. else
  335.   echo shar: Extracting \"'util/script'\" \(299 characters\)
  336.   sed "s/^X//" >'util/script' <<'END_OF_FILE'
  337. X#!/bin/sh
  338. X# Public domain.
  339. Xcase "$@" in
  340. X"") extra=typescript ;;
  341. X"-a") extra=typescript ;;
  342. X"-i") extra=typescript ;;
  343. X"-a -i") extra=typescript ;;
  344. Xesac
  345. Xecho "Script started, teeing $@" "$extra"
  346. X( echo 'Script started on '`date`;
  347. X  pty -s "$SHELL";
  348. X  echo 'Script done on '`date` ) | tee "$@" "$extra"
  349. END_OF_FILE
  350.   if test 299 -ne `wc -c <'util/script'`; then
  351.     echo shar: \"'util/script'\" unpacked with wrong size!
  352.   fi
  353.   chmod +x 'util/script'
  354.   # end of 'util/script'
  355. fi
  356. if test -f 'util/script.tidy' -a "${1}" != "-c" ; then 
  357.   echo shar: Will not clobber existing file \"'util/script.tidy'\"
  358. else
  359.   echo shar: Extracting \"'util/script.tidy'\" \(63 characters\)
  360.   sed "s/^X//" >'util/script.tidy' <<'END_OF_FILE'
  361. X#!/bin/sh
  362. X# Public domain.
  363. Xexec sed -e 's/$//' -e 's/[^]//g'
  364. END_OF_FILE
  365.   echo shar: 2 control characters may be missing from \"'util/script.tidy'\"
  366.   if test 63 -ne `wc -c <'util/script.tidy'`; then
  367.     echo shar: \"'util/script.tidy'\" unpacked with wrong size!
  368.   fi
  369.   chmod +x 'util/script.tidy'
  370.   # end of 'util/script.tidy'
  371. fi
  372. if test -f 'util/sess' -a "${1}" != "-c" ; then 
  373.   echo shar: Will not clobber existing file \"'util/sess'\"
  374. else
  375.   echo shar: Extracting \"'util/sess'\" \(44 characters\)
  376.   sed "s/^X//" >'util/sess' <<'END_OF_FILE'
  377. X#!/bin/sh
  378. X# Public domain.
  379. Xexec pty -s "$@"
  380. END_OF_FILE
  381.   if test 44 -ne `wc -c <'util/sess'`; then
  382.     echo shar: \"'util/sess'\" unpacked with wrong size!
  383.   fi
  384.   chmod +x 'util/sess'
  385.   # end of 'util/sess'
  386. fi
  387. if test -f 'util/tiocsti.1' -a "${1}" != "-c" ; then 
  388.   echo shar: Will not clobber existing file \"'util/tiocsti.1'\"
  389. else
  390.   echo shar: Extracting \"'util/tiocsti.1'\" \(250 characters\)
  391.   sed "s/^X//" >'util/tiocsti.1' <<'END_OF_FILE'
  392. X.TH tiocsti 1
  393. X.SH NAME
  394. Xtiocsti \- simulate terminal input
  395. X.SH SYNOPSIS
  396. X.B tiocsti
  397. X[
  398. X.I arg
  399. X] ...
  400. X.SH DESCRIPTION
  401. X.I tiocsti
  402. X``types'' each of its arguments on the
  403. Xcurrent terminal, separated by spaces,
  404. Xas if you had typed them.
  405. X.SH "SEE ALSO"
  406. Xtty(4)
  407. END_OF_FILE
  408.   if test 250 -ne `wc -c <'util/tiocsti.1'`; then
  409.     echo shar: \"'util/tiocsti.1'\" unpacked with wrong size!
  410.   fi
  411.   # end of 'util/tiocsti.1'
  412. fi
  413. if test -f 'util/tiocsti.c' -a "${1}" != "-c" ; then 
  414.   echo shar: Will not clobber existing file \"'util/tiocsti.c'\"
  415. else
  416.   echo shar: Extracting \"'util/tiocsti.c'\" \(322 characters\)
  417.   sed "s/^X//" >'util/tiocsti.c' <<'END_OF_FILE'
  418. X/* Public domain. */
  419. X#include <sys/ioctl.h>
  420. X
  421. Xmain(argc,argv)
  422. Xint argc;
  423. Xchar *argv[];
  424. X{
  425. X int j;
  426. X char *s;
  427. X
  428. X if (ioctl(3,TIOCGPGRP,(char *) &j) == -1)
  429. X   (void) dup2(0,3);
  430. X
  431. X for (j = 1;j < argc;j++)
  432. X  {
  433. X   for (s = argv[j];*s;s++)
  434. X     (void) ioctl(3,TIOCSTI,s);
  435. X   if (j < argc - 1)
  436. X     (void) ioctl(3,TIOCSTI," ");
  437. X  }
  438. X}
  439. END_OF_FILE
  440.   if test 322 -ne `wc -c <'util/tiocsti.c'`; then
  441.     echo shar: \"'util/tiocsti.c'\" unpacked with wrong size!
  442.   fi
  443.   # end of 'util/tiocsti.c'
  444. fi
  445. if test -f 'util/tty.1' -a "${1}" != "-c" ; then 
  446.   echo shar: Will not clobber existing file \"'util/tty.1'\"
  447. else
  448.   echo shar: Extracting \"'util/tty.1'\" \(279 characters\)
  449.   sed "s/^X//" >'util/tty.1' <<'END_OF_FILE'
  450. X.TH tty 1
  451. X.SH NAME
  452. Xtty \- get terminal name
  453. X.SH SYNOPSIS
  454. X.B tty
  455. X[
  456. X.B\-s
  457. X]
  458. X.SH DESCRIPTION
  459. X.I tty
  460. Xprints the pathname of the user's terminal,
  461. Xor
  462. X``not a tty''
  463. Xif its input is not a terminal.
  464. X.I tty \-s
  465. Xprints nothing.
  466. X.SH "EXIT VALUE"
  467. X0 if the input is a terminal,
  468. X1 if it isn't.
  469. END_OF_FILE
  470.   if test 279 -ne `wc -c <'util/tty.1'`; then
  471.     echo shar: \"'util/tty.1'\" unpacked with wrong size!
  472.   fi
  473.   # end of 'util/tty.1'
  474. fi
  475. if test -f 'util/tty.c' -a "${1}" != "-c" ; then 
  476.   echo shar: Will not clobber existing file \"'util/tty.c'\"
  477. else
  478.   echo shar: Extracting \"'util/tty.c'\" \(298 characters\)
  479.   sed "s/^X//" >'util/tty.c' <<'END_OF_FILE'
  480. X/* Public domain. */
  481. X
  482. Xextern char *ttyname();
  483. X
  484. Xmain(argc,argv)
  485. Xint argc;
  486. Xchar *argv[];
  487. X{
  488. X char *s;
  489. X
  490. X s = ttyname(0);
  491. X
  492. X if ((argc != 2)
  493. X   ||(argv[1][0] != '-') || (argv[1][1] != 's') || (argv[1][2] != '\0'))
  494. X   if (s)
  495. X     (void) puts(s);
  496. X   else
  497. X     (void) puts("not a tty");
  498. X (void) exit(!s);
  499. X}
  500. END_OF_FILE
  501.   if test 298 -ne `wc -c <'util/tty.c'`; then
  502.     echo shar: \"'util/tty.c'\" unpacked with wrong size!
  503.   fi
  504.   # end of 'util/tty.c'
  505. fi
  506. echo shar: End of archive 6 \(of 6\).
  507. cp /dev/null ark6isdone
  508. MISSING=""
  509. for I in 1 2 3 4 5 6 ; do
  510.     if test ! -f ark${I}isdone ; then
  511.     MISSING="${MISSING} ${I}"
  512.     fi
  513. done
  514. if test "${MISSING}" = "" ; then
  515.     echo You have unpacked all 6 archives.
  516.     rm -f ark[1-9]isdone
  517. else
  518.     echo You still must unpack the following archives:
  519.     echo "        " ${MISSING}
  520. fi
  521. exit 0
  522. exit 0 # Just in case...
  523. -- 
  524. Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
  525. Use a domain-based address or give alternate paths, or you may lose out.
  526.